package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author: 夏帮连
 * @date: 2025/06/11
 * @description:
 * @version: 1.0
 */
@Mapper
public interface SetmealMapper {
    @Select("select IFNULL(count(id), 0) from dish where category_id=#{id}")
    int countByCatoryId(Long id);
    @Select("select * from setmeal where status=#{status} and category_id=#{categoryId}")
    List<Setmeal> list(Setmeal setmeal);
    @Select("select sd.copies,sd.name,d.image,d.description from setmeal_dish sd left join dish d on sd.dish_id = d.id where sd.setmeal_id=#{id}")
    List<DishItemVO> getDishItemVOBySetmealId(Long id);

    void save(Setmeal setmeal);
    @Select("select * from setmeal where id=#{id}")
    Setmeal getById(Long id);

    void update(Setmeal setmeal);

    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);
    @Delete("delete from setmeal where id=#{id}")
    void deleteById(Long id);
    @Select("select IFNULL(count(id), 0) from setmeal where status =#{status}")
    Integer countByStatus(Integer status);
}
